< previous page page_580 next page >

Page 580
general surfaces. Program GZOrder uses calculus to explicitly find vertex normals. If your calculus is a little rusty, do not worry too much about this. Feel free to skip to the next section.
If F(x, y) is the equation of a surface, a normal vector to the surface at point (x, y) is given by the equation's partial derivatives:
e10a6a0a59f035e870d90cca05b85fce.gif
<F/x (x, y), F/y (x, y), -1>
For example, the surface shown in Figure 16.15 has the following equation. The roles of the Y and Z coordinates are reversed to match the right-handed coordinate system used by the projection code.
e10a6a0a59f035e870d90cca05b85fce.gif
Y = Amplitude1 * (Cos(Period1 * X) + Cos(Period1 * Z))
The partial derivatives of this equation with respect to X and Z are:
e10a6a0a59f035e870d90cca05b85fce.gif
F/x = amplitude1 * Period1 * Sin(Period1 * X)
F/z = Amplitude1 * Period1 * Sin(Period1 * Z)
Program GZOrder uses these equations to find the vertex normals for the surface.
0580-01.jpg
Figure 16.15
Program GZOrder displaying a surface with Gouraud shading.

 
< previous page page_580 next page >